import fetch from 'utils/fetch'

// 获取圆梦商品列表
export function getDreamList(data) {
  return fetch({
    url: '/dream/list/',
    method: 'get',
    params: data
  })
}

// 获取圆梦商品详情
export function getDreamDetail(data) {
  return fetch({
    url: '/dream/detail/',
    method: 'get',
    params: data
  })
}

export function buyDream(data) {
  return fetch({
    url: '/dream/buy/',
    method: 'post',
    data,
    transformRequest: [function(data) {
      // Do whatever you want to transform the data
      let ret = ''
      for (const it in data) {
        ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&'
      }
      return ret
    }],
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    }
  })
}

// 获取我的圆梦码
export function getMyDCode(data) {
  return fetch({
    url: '/dream/mycode/',
    method: 'get',
    params: data
  })
}

// 获取我的圆梦列表
export function getMyDream(data) {
  return fetch({
    url: '/dream/mydream/',
    method: 'get',
    params: data
  })
}